package com.mybatis.flex.listener;

import com.mybatis.flex.entity.Account;
import com.mybatisflex.annotation.SetListener;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;



public class FlexSetListener implements SetListener {
    @Override
    public Object onSet(Object entity, String property, Object value) {
        Account account = (Account) entity;
        if (property.equals("sex") && value != null){
            String val=(String)value;
            if ("0".equals(val)) {
                account.setSex("女");
            } else if  ("1".equals(val)) {
                account.setSex("男");
            } else {
                account.setSex("未知");
            }
        }
        return value;
    }
}
